<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>生产周报表</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<link rel="stylesheet" href="${pageContext.request.contextPath }/assets/css/layui.css"  media="all">
	<link rel="stylesheet" href="${pageContext.request.contextPath }/assets/css/toastr.min.css"  media="all">
</head>
<body>
<div class="demoTable" style="padding:10px 0 0 15px">
    	日期<div class="layui-inline">
        	<input class="layui-input" name="time" id="time" autocomplete="off">
    	</div>
    	班组名称<div class="layui-inline">
    		<select class="layui-input" name="teamName" id="teamName" autocomplete="off">
    			<option value=""> --请选择班组   - -</option>
    			<option value="白班">白班</option>
    			<option value="晚班">晚班</option>
    		</select>
    	</div>
    	<button class="layui-btn layui-btn-blue" style="margin: 0 0 0 10px" data-type="reload"><i class="layui-icon layui-icon-search">  搜索</i></button>
</div>

<table class="layui-hide" id="test" lay-filter="test"></table>
<script type="text/html" id="toolbarDemo">
	<div class="layui-btn-container">
	</div>
</script>

<script src="${pageContext.request.contextPath }/assets/layui.js" charset="utf-8"></script>
<script src="${pageContext.request.contextPath }/assets/layui.all.js"></script>
<script src="${pageContext.request.contextPath }/assets/js/jquery.min.js" charset="utf-8"></script>
<script src="${pageContext.request.contextPath }/assets/js/toastr.min.js" charset="utf-8"></script>
<script src="https://img.hcharts.cn/highcharts/highcharts.js"></script>
<script src="https://img.hcharts.cn/highcharts/modules/exporting.js"></script>
<script src="https://img.hcharts.cn/highcharts-plugins/highcharts-zh_CN.js"></script>
 
<script>
layui.use(['table','layer','upload','form','carousel'], function(){
	var carousel = layui.carousel;
	var table = layui.table;
	var layer = layui.layer,
    form = layui.form;
	var laydate = layui.laydate;
	carousel.render({
	    elem: '#test1'
	    ,interval: 5000
	    ,anim: 'fade'
	    ,height: '400px'
	    ,width: '100%'
	    ,arrow: 'none'
	    ,indicator: 'none'
	});
	//执行一个laydate实例
	laydate.render({
		elem: '#time' //指定元素
	});
	var $ = layui.jquery, active = {
			reload:function () {
				var time = $("#time").val();
				var teamName = $("#teamName").val();
				console.log(time)
				table.reload('contenttable',{
					method:'get',
					where:{time: time, teamName:teamName}
				});
			}
		}
	$('.layui-btn').on('click', function(){
        var type = $(this).data('type');
        active[type] ? active[type].call(this) : '';
    });
	table.render({
	    elem: '#test'
	    ,url:'${pageContext.request.contextPath }/report/weeklyreport.do'
	    ,title: '生产报表'
		,height: 400
		//,toolbar: '#toolbarDemo'
	    ,id :'contenttable'
	    //,limits:[10,20,30]
	    ,cols: [[
	      //{type: 'checkbox', fixed: 'left', rowspan: 2}
	      {type: 'numbers', title:'序号', fixed: 'left', rowspan: 2, width:'5%', unresize: true, sort: true}
	      ,{field:'stationName', title:'工位名称', rowspan: 2, align:'center'}
	      ,{field:'', title:'0960T', colspan: 3, align:'center'}
	      ,{field:'', title:'0980T', colspan: 3, align:'center'}
	      ,{field:'', title:'1080C', colspan: 3, align:'center'}
	      ,{field:'', title:'1060B', colspan: 3, align:'center'}
	    ],
	    [
	      {field:'planAmount1', title:'计划量', align:'center', templet: function(d){
	    	  console.log(d)
	    	  return d.productStatusList[0].planAmount;
	      }}
	      /* {field:'lastPlanAmount1', title:'剩余计划量', align:'center', templet: function(d){
	    	  return d.productStatusList[0].lastPlanAmount;
	      }} */
	      ,{field:'completeAmount1', title:'完成量', align:'center', templet: function(d){
	    	  return d.productStatusList[0].completeAmount;
	      }}
	      ,{field:'productivity1', title:'生产率', align:'center', templet: function(d){
	    	 if (d.productStatusList[0].completeAmount > d.productStatusList[0].planAmount) {
	    		  return '100%';
			} else {
				if ('.00%' == d.productStatusList[0].productivity) {
		    		  return 0;
				} else {
					return d.productStatusList[0].productivity;
				}
			}
	      }}
	      ,{field:'planAmount2', title:'计划量', align:'center', templet: function(d){
	    	  return d.productStatusList[1].planAmount;
	      }}
	      /* ,{field:'lastPlanAmount2', title:'剩余计划量', align:'center', templet: function(d){
	    	  return d.productStatusList[1].lastPlanAmount;
	      }} */
	      ,{field:'completeAmount2', title:'完成量', align:'center', templet: function(d){
	    	  return d.productStatusList[1].completeAmount;
	      }}
	      ,{field:'productivity2', title:'生产率', align:'center', templet: function(d){
	    	if (d.productStatusList[0].completeAmount > d.productStatusList[0].planAmount) {
	    		  return '100%';
			} else {
				if ('.00%' == d.productStatusList[1].productivity) {
		    		  return 0;
				} else {
					return d.productStatusList[1].productivity;
				}
			}
	      }}
	      ,{field:'planAmount3', title:'计划量', align:'center', templet: function(d){
	    	  return d.productStatusList[2].planAmount;
	      }}
	      /* ,{field:'lastPlanAmount3', title:'剩余计划量', align:'center', templet: function(d){
	    	  return d.productStatusList[2].lastPlanAmount;
	      }} */
	      ,{field:'completeAmount3', title:'完成量', align:'center', templet: function(d){
	    	  return d.productStatusList[2].completeAmount;
	      }}
	      ,{field:'productivity3', title:'生产率', align:'center', templet: function(d){
	    	if (d.productStatusList[0].completeAmount > d.productStatusList[0].planAmount) {
	    		return '100%';
			} else {
				if ('.00%' == d.productStatusList[2].productivity) {
		    		  return 0;
				} else {
					return d.productStatusList[2].productivity;
				}
			}
	      }}
	      ,{field:'planAmount4', title:'计划量', align:'center', templet: function(d){
	    	  return d.productStatusList[3].planAmount;
	      }}
	      /* ,{field:'lastPlanAmount4', title:'剩余计划量', align:'center', templet: function(d){
	    	  return d.productStatusList[3].lastPlanAmount;
	      }} */
	      ,{field:'completeAmount4', title:'完成量', align:'center', templet: function(d){
	    	  return d.productStatusList[3].completeAmount;
	      }}
	      ,{field:'productivity4', title:'生产率', align:'center', templet: function(d){
	    	if (d.productStatusList[0].completeAmount > d.productStatusList[0].planAmount) {
	    		return '100%';
			} else {
				if ('.00%' == d.productStatusList[3].productivity) {
		    		  return 0;
				} else {
					return d.productStatusList[3].productivity;
				}
			}
	      }}
	    ]]
	    ,page: false
	});
});

toastr.options.positionClass = 'toast-top-center'; //提示框的位置设置为中上
</script>

</body>
</html>